package com.outdoor.server.controller.admin;

import com.outdoor.common.result.PageResult;
import com.outdoor.common.result.Result;
import com.outdoor.pojo.dto.TracePageQueryDTO;
import com.outdoor.pojo.entity.Trace;
import com.outdoor.pojo.vo.TraceVO;
import com.outdoor.server.service.TraceService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/trace")
@Slf4j
public class TraceController {

    @Autowired
    private TraceService traceService;
    /**
     * 分页查询路线信息
     * @param tracePageQueryDTO
     * @return
     */
    @GetMapping("/page")
    public Result<PageResult> page(TracePageQueryDTO tracePageQueryDTO) {
        log.info("tracePageQueryDTO: {}", tracePageQueryDTO);
        PageResult pageResult = traceService.page(tracePageQueryDTO);
        return Result.success(pageResult);
    }
    /**
     * 查询路线详情
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result<TraceVO> getById(@PathVariable Integer id) {
        TraceVO traceVO = traceService.getById(id);
        return Result.success(traceVO);
    }
    /**
     * 路线启用禁用
     * @param status
     * @param id
     * @return
     */
    @PostMapping("/status/{status}")
    public Result updateStatus(@PathVariable Integer status,Long id) {
        traceService.updateStatus(status,id);
        return Result.success();
    }
}
